<template>
    <el-select v-model="selectedValue" placeholder="All" @change="changeHandler" clearable >
        <el-option v-for="sd in dictData" :key="sd.code" :label="sd.name" :value="sd.code"></el-option>
    </el-select>
</template>


<script setup>

import usedictStore from '@/store/app/dict';
const dictStore = usedictStore();
const dictData =ref([]);

const props = defineProps({
    
    modelValue:{
        type:Number,
        require:true,
        default:null
    },

    classCode: {
        type: String,
        require: true
    }
});

const selectedValue = ref(props.modelValue);
const emits = defineEmits(['update:modelValue']);

const changeHandler = (val)=>{
    selectedValue.value = val;
    emits('update:modelValue',val);
}

onMounted(async ()=>{
    const res = await dictStore.getDictdata(props.classCode);
    dictData.value = res.data.data;
});
</script>
